﻿using FoodModel;
using J.FoodManageGet.Application.Command.BenchTableCommand;
using J.FoodManageGet.Application.Command.DishesCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace J.FoodManageGet.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DishesController : ControllerBase
    {
        private readonly IMediator _mediator;

        public DishesController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 菜品反填
        /// </summary>
        [HttpPost]
        public async Task<DishesModel> DishesBack(DishesBackCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 菜品名称显示
        /// </summary>
        [HttpPost]
        public async Task<List<DishesModel>> Dishes(DishesCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 菜品显示
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> DishesShow(DishesShowCommand command)
        {
            var list = await _mediator.Send(command);
            return Ok(new
            {
                list.totalCount,
                list.PagCount,
                list.list
            });
        }

    }
}
